Expand description

This crate provides wrappers for Micorosft’s SEAL Homomorphic encryption library.

Notes

All types in this crate implement Sync/Send. So long as you never dereference the internal handle on any type after it has been dropped, these traits should safely hold. The internal handles should be of little use to you anyways.

This crate intentionally omits more esoteric use cases to streamline the API and is currently incomplete (e.g. CKKS is not currently supported). If any underlying SEAL API you care about is missing, please add it in a pull request or file an issue.

Structs

Provides functionality for CRT batching. If the polynomial modulus degree is N, and the plaintext modulus is a prime number T such that T is congruent to 1 modulo 2N, then BatchEncoder allows the plaintext elements to be viewed as 2-by-(N/2) matrices of integers modulo T. Homomorphic operations performed on such encrypted matrices are applied coefficient (slot) wise, enabling powerful Batched functionality for computations that are vectorizable. This functionality is often called “batching” in the homomorphic encryption literature.

An evaluator that contains additional operations specific to the BFV scheme.

Creates an encoder that can turn i64 or u64 values into a Plaintext. This encoder is not recommended as it’s an inefficient use of the plain modulus space.

Represents a builder that sets up and creates encryption scheme parameters. The parameters (most importantly PolyModulus, CoeffModulus, PlainModulus) significantly affect the performance, capabilities, and security of the encryption scheme.

Class to store a ciphertext element. The data for a ciphertext consists of two or more polynomials, which are in Microsoft SEAL stored in a CRT form with respect to the factors of the coefficient modulus. This data itself is not meant to be modified directly by the user, but is instead operated on by functions in the Evaluator class. The size of the backing array of a ciphertext depends on the encryption parameters and the size of the ciphertext (at least 2). If the PolyModulusDegree encryption parameter is N, and the number of primes in the CoeffModulus encryption parameter is K, then the ciphertext backing array requires precisely 8NK*size bytes of memory. A ciphertext also carries with it the parmsId of its associated encryption parameters, which is used to check the validity of the ciphertext for homomorphic operations and decryption.

This struct contains static methods for creating a coefficient modulus easily. Note that while these functions take a SecLevelType argument, all security guarantees are lost if the output is used with encryption parameters with a mismatching value for the PolyModulusDegree.

Performs sanity checks (validation) and pre-computations for a given set of encryption parameters. While the EncryptionParameters class is intended to be a light-weight class to store the encryption parameters, the SEALContext class is a heavy-weight class that is constructed from a given set of encryption parameters. It validates the parameters for correctness, evaluates their properties, and performs and stores the results of several costly pre-computations.

Decrypts Ciphertext objects into Plaintext objects. Constructing a Decryptor requires a SEALContext with valid encryption parameters, and the secret key. The Decryptor is also used to compute the invariant noise budget in a given ciphertext.

An immutable collection of parameters that defines an encryption scheme. Use either the CKKSBuilder or BFVBuilder to create one of these. Once created, these objects are effectively immutable.

Encrypts Plaintext objects into Ciphertext objects.

Class to store Galois keys.

Generates matching secret key and public key. An existing KeyGenerator can also at any time be used to generate relinearization keys and Galois keys. Constructing a KeyGenerator requires only a SEALContext.

Represent an integer modulus of up to 61 bits. An instance of the Modulus struct represents a non-negative integer modulus up to 61 bits. In particular, the encryption parameter PlainModulus, and the primes in CoeffModulus, are represented by instances of Modulus. The purpose of this class is to perform and store the pre-computation required by Barrett reduction.

Methods for easily constructing plaintext modulus

Class to store a plaintext element. The data for the plaintext is a polynomial with coefficients modulo the plaintext modulus. The degree of the plaintext polynomial must be one less than the degree of the polynomial modulus. The backing array always allocates one 64-bit word per each coefficient of the polynomial.

Class to store a public key.

Class to store relinearization keys.

Class to store a secret key.

Enums

A type representing all errors that can occur in SEAL.

The FHE scheme supported by SEAL.

Represents a standard security level according to the HomomorphicEncryption.org security standard. The value SecLevelType.None signals that no standard security level should be imposed. The value SecLevelType.TC128 provides a very high level of security and is the default security level enforced by Microsoft SEAL when constructing a SEALContext object. Normal users should not have to specify the security level explicitly anywhere.

Traits

An interface for an evaluator.

A trait for converting data from a byte slice under a given SEAL context.

A trait for converting objects into byte arrays.

Type Definitions

type Result<T> = std::result::Result<T, Error>;.